Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@gramio/keyboards
Advanced tools
Framework-agnostic Telegram bot keyboard (and inline query result) builder with many cool features!
npm i @gramio/keyboards
import { Keyboard } from "@gramio/keyboards";
const keyboard = new Keyboard()
.text("first row")
.row()
.text("second row")
.build(); // NOTE: In GramIO, you don't have to use the ".build" method
import { Bot, Keyboard } from "gramio"; // import from GramIO package!!
const bot = new Bot(process.env.TOKEN as string);
const data = ["Apple", "Realme", "Tesla", "Xiaomi"];
bot.on("message", (ctx) => {
return ctx.send("test", {
reply_markup: new Keyboard()
.columns(1)
.text("simple keyboard")
.add(...data.map((x) => Keyboard.text(x)))
.filter(({ button }) => button.text !== "Tesla"),
});
});
import { Keyboard } from "@gramio/keyboards";
import { Bot } from "grammy";
const bot = new Bot(process.env.TOKEN as string);
const data = ["Apple", "Realme", "Tesla", "Xiaomi"];
bot.on("message", (ctx) => {
return ctx.reply("test", {
reply_markup: new Keyboard()
.columns(1)
.text("simple keyboard")
.add(...data.map((x) => Keyboard.text(x)))
.filter(({ button }) => button.text !== "Tesla")
.build(),
});
});
bot.start();
[!WARNING] The
Telegraf
does not support the latest version of Bot API
import { Keyboard } from "@gramio/keyboards";
import { Telegraf } from "telegraf";
const bot = new Telegraf(process.env.TOKEN as string);
const data = ["Apple", "Realme", "Tesla", "Xiaomi"];
bot.on("message", (ctx) => {
return ctx.reply("test", {
reply_markup: new Keyboard()
.columns(1)
.text("simple keyboard")
.add(...data.map((x) => Keyboard.text(x)))
.filter(({ button }) => button.text !== "Tesla")
.build(),
});
});
bot.launch();
import { Telegram } from "puregram";
import { Keyboard } from "@gramio/keyboards";
const bot = new Telegram({
token: process.env.TOKEN as string,
});
const data = ["Apple", "Realme", "Tesla", "Xiaomi"];
bot.on("message", (ctx) => {
return ctx.send("test", {
reply_markup: new Keyboard()
.columns(1)
.text("simple keyboard")
.add(...data.map((x) => Keyboard.text(x)))
.filter(({ button }) => button.text !== "Tesla")
.build(),
});
});
bot.updates.startPolling();
[!WARNING] The
node-telegram-bot-api
does not support the latest version of Bot API and the types are badly written, so the types may not match
import { Keyboard } from "@gramio/keyboards";
import TelegramBot from "node-telegram-bot-api";
const bot = new TelegramBot(process.env.TOKEN as string, { polling: true });
const data = ["Apple", "Realme", "Tesla", "Xiaomi"];
bot.on("message", (msg) => {
return bot.sendMessage(msg.chat.id, "test", {
reply_markup: new Keyboard()
.columns(1)
.text("simple keyboard")
.add(...data.map((x) => Keyboard.text(x)))
.filter(({ button }) => button.text !== "Tesla")
.build(),
});
});
{
"keyboard": [
[
{
"text": "simple keyboard"
}
],
[
{
"text": "Apple"
}
],
[
{
"text": "Realme"
}
],
[
{
"text": "Xiaomi"
}
]
],
"one_time_keyboard": false,
"is_persistent": false,
"selective": false,
"resize_keyboard": true
}
FAQs
Framework-agnostic Telegram bot keyboard builder with many cool features!
The npm package @gramio/keyboards receives a total of 255 weekly downloads. As such, @gramio/keyboards popularity was classified as not popular.
We found that @gramio/keyboards demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.